]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shellMountDialog: Close all dialogs when pressing Escape key
authorJonas Dreßler <verdre@v0yd.nl>
Mon, 27 Jan 2020 17:46:17 +0000 (18:46 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Mon, 27 Jan 2020 23:22:46 +0000 (23:22 +0000)
Since we don't really know what the buttons we're adding to the dialogs
are about, we can't configure a button to "be clicked" when the escape
key is pressed. So add a separate escape key handler to fix that, return
-1 and abort the request.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/961

js/ui/shellMountOperation.js

index 59a4e6e0fe21c63ca1bb3cb2f1119abbc42f96ec..b2aa2ac47aa09efcc00654823e44a2e47226787f 100644 (file)
@@ -236,6 +236,15 @@ var ShellMountQuestionDialog = GObject.registerClass({
         this.contentLayout.add_child(this._content);
     }
 
+    vfunc_key_release_event(event) {
+        if (event.keyval === Clutter.KEY_Escape) {
+            this.emit('response', -1);
+            return Clutter.EVENT_STOP;
+        }
+
+        return Clutter.EVENT_PROPAGATE;
+    }
+
     update(message, choices) {
         _setLabelsForMessage(this._content, message);
         _setButtonsForChoices(this, this._oldChoices, choices);
@@ -481,7 +490,13 @@ var ShellProcessesDialog = GObject.registerClass({
         this.contentLayout.add_child(this._applicationSection);
     }
 
+    vfunc_key_release_event(event) {
+        if (event.keyval === Clutter.KEY_Escape) {
+            this.emit('response', -1);
+            return Clutter.EVENT_STOP;
+        }
 
+        return Clutter.EVENT_PROPAGATE;
     }
 
     _setAppsForPids(pids) {
@@ -662,8 +677,17 @@ var GnomeShellMountOpHandler = class {
 
         this._dialog = new ShellMountQuestionDialog(message);
         this._dialog.connect('response', (object, choice) => {
-            this._clearCurrentRequest(Gio.MountOperationResult.HANDLED,
-                                      { choice: GLib.Variant.new('i', choice) });
+            let response;
+            let details = {};
+
+            if (choice == -1) {
+                response = Gio.MountOperationResult.ABORTED;
+            } else {
+                response = Gio.MountOperationResult.HANDLED;
+                details['choice'] = GLib.Variant.new('i', choice);
+            }
+
+            this._clearCurrentRequest(response, details);
         });
 
         this._dialog.update(message, choices);